<?

include('sys/init.php');

$current_user = hello();

$where   = preg_replace('/[^a-z]/', ' ', $_POST['where']);
$canedit = (is_array($current_user)) ? check_user_right('sections', 'edit_'.$where, $current_user['rights']) : false;

//if ($where != 'types' && $where != 'places') die('oops!'); // - we've checked it while we check rights.

if (!$canedit) die('oops?!');

$what = (isset($_POST['what'])) ? justwords($_POST['what']) : '';


//------------------------------------------------------------------------------

// now we should add new item to rfc

if($what=='addnew')
{
   $name = check_rfc_item($_POST['name']);
      
   if( $name )
      add_reference($name, $where);

   $out = get_rfc_html($where, $canedit, 'just table, pls');
   die($out);
}

///-----------------------------------------------------------------------------

// now we should delete an item from rfc

elseif ($what=='delete')
{
   $id = justdigs($_POST['id']);
   
   if( $id>0 )
      del_reference($id, $where);
   
   $out = get_rfc_html($where, $canedit, 'just table, pls');
   die($out);
}

//------------------------------------------------------------------------------

// and now we should edit some item in rfc

elseif ($what=='edit')
{
   $id  = justdigs($_POST['id']);
   $num = justdigs($_POST['num']);
   $name = check_rfc_item($_POST['name']);

   $arr = array('id' => $id, 'num' => $num, 'name' => $name);
   
   if( $id>0 && $name )
      edit_reference($arr, $where);
   
   $out = get_rfc_html($where, $canedit, 'just table, pls');
   die($out);
}

//------------------------------------------------------------------------------
//

elseif( $what=='order' && is_array($_POST['refTbl']) )
{
   $order = $_POST['refTbl'];
   
   set_ref_order($where, $order);
   
   $out = get_rfc_html($where, $canedit, 'just table, pls');
   die($out);
}

else die('oops?');



































?>
